<template>
	<AdminLayout 
		activeKey="post-audit" 
		:breadcrumbs="['首页','帖子审核']" 
		tabTitle="帖子审核"
		:loading="isLoading"
		:skeletonItemCount="6"
	>
		<view class="page">
			<view class="section-header">
				<text class="section-title">帖子审核</text>
				<text class="section-desc">审核校园圈子中的帖子内容，管理用户发布的讨论、问答、失物招领等</text>
			</view>

			<!-- 筛选工具栏 -->
			<view class="filter-toolbar">
				<input 
					class="search-input" 
					v-model="filters.keyword" 
					placeholder="搜索帖子内容或发布者" 
					@input="onSearchInput"
					@confirm="onSearchConfirm"
				/>
				<picker mode="selector" :range="categoryOptions" @change="onCategoryChange">
					<view class="picker-btn">分类：{{ filters.category || '全部' }}</view>
				</picker>
				<picker mode="selector" :range="statusOptions" @change="onStatusChange">
					<view class="picker-btn">状态：{{ filters.status || '全部' }}</view>
				</picker>
				<button class="filter-btn" @click="loadPosts">刷新</button>
			</view>

			<scroll-view scroll-y class="content-list">
				<view v-for="post in postList" :key="post._id" class="content-item" 
				      :class="{
				        violation: isViolationPost(post),
				        pending: post.status === 'pending_review',
				        approved: post.status === 'reviewed_approved',
				        rejected: post.status === 'reviewed_rejected'
				      }">
					<view class="content-header">
						<view class="content-meta">
							<text class="content-category">{{ post.category }}</text>
							<text class="content-status" :class="post.status">{{ getStatusText(post.status) }}</text>
							<text class="like-count">点赞：{{ post.like_count }}</text>
							<text class="comment-count">评论：{{ post.comment_count }}</text>
						</view>
						<text class="publish-time">{{ formatTime(post.create_time) }}</text>
					</view>
					
					<view class="content-main">
						<text class="content-text">{{ post.content }}</text>
						<view class="publisher-info">
							<text>发布者：{{ post.publisher?.nickname || post.user_info?.nickname || post.user_info?.username || post.publisher_name || '未知用户' }}</text>
						</view>
					</view>

					<view class="content-actions">
						<!-- 审核按钮组 -->
						<view v-if="getAvailableActions(post).length > 0" class="audit-actions">
							<button 
								v-for="action in getAvailableActions(post)" 
								:key="action.key"
								class="audit-btn"
								:class="{
									'approve': action.key === 'reviewed_approved' || action.key === 'published',
									'reject': action.key === 'reviewed_rejected' || action.key === 'pending_review',
									'warn': action.key === 'hidden'
								}"
								@click="auditPost(post, action.key, action.text)"
							>
								<text class="audit-icon">{{ action.icon }}</text>
								<text>{{ action.text }}</text>
							</button>
						</view>
						
						<button size="mini" @click="editPost(post)">编辑</button>
						<button size="mini" @click="pinPost(post)">{{ post.pinned ? '取消置顶' : '置顶' }}</button>
						<button size="mini" type="danger" @click="deletePost(post)">删除</button>
						<button v-if="isViolationPost(post)" size="mini" type="warn" @click="warnUser(post)">警告用户</button>
					</view>
				</view>
			</scroll-view>
		</view>

		<!-- 编辑帖子弹窗 -->
		<view v-if="showEditModal" class="modal-overlay" @click="closeEditModal">
			<view class="modal-content" @click.stop>
				<view class="modal-header">
					<text class="modal-title">编辑帖子</text>
					<text class="modal-close" @click="closeEditModal">×</text>
				</view>
				
				<scroll-view scroll-y class="modal-body">
					<view class="form-group">
						<text class="form-label">帖子标题（可选）</text>
						<input class="form-input" v-model="editForm.title" placeholder="请输入帖子标题" />
					</view>
					
					<view class="form-group">
						<text class="form-label">帖子分类</text>
						<picker mode="selector" :range="categoryOptions.slice(1)" @change="onEditCategoryChange" class="picker-wrapper">
							<view class="form-picker">{{ editForm.category || '请选择帖子分类' }}</view>
						</picker>
					</view>
					
					<view class="form-group">
						<text class="form-label">帖子内容 *</text>
						<textarea class="form-textarea" v-model="editForm.content" placeholder="请输入帖子内容" />
					</view>
				</scroll-view>
				
				<view class="modal-footer">
					<button class="modal-btn cancel-btn" @click="closeEditModal">取消</button>
					<button class="modal-btn confirm-btn" @click="saveEdit">保存</button>
				</view>
			</view>
		</view>
	</AdminLayout>
</template>

<script>
import AdminLayout from '@/components/AdminLayout.vue'
const SENSITIVE = ['违法','敏感','诈骗','广告','性','黄','毒','赌']

export default {
	components: { AdminLayout },
	data() {
		return {
			postList: [],
			allPostList: [], // 存储所有帖子数据，用于本地搜索
			filters: {
				keyword: '',
				category: '',
				status: ''
			},
			categoryOptions: ['全部', '讨论', '问答', '吐槽','表白','失物招领', '其他'],
			statusOptions: ['全部', '待审核', '已发布', '已审核通过', '已审核拒绝', '已隐藏', '已删除'],
			isLoading: false,
			searchTimer: null, // 搜索防抖定时器
			showEditModal: false, // 控制编辑弹窗显示
			currentEditPost: null, // 当前编辑的帖子
			editForm: {
				title: '',
				content: '',
				category: ''
			}
		}
	},

	mounted() {
		// 延迟执行，确保DOM渲染完成
		this.$nextTick(() => {
			this.loadPosts()
		})
	},

	methods: {
		// 时间格式化
		formatTime(v) {
			if (!v) return '--'
			const d = new Date(v)
			const p = n => String(n).padStart(2, '0')
			return `${d.getFullYear()}-${p(d.getMonth() + 1)}-${p(d.getDate())} ${p(d.getHours())}:${p(d.getMinutes())}`
		},

		// 检测敏感内容
		isSensitive(text = '') {
			return SENSITIVE.some(k => text.includes(k))
		},

		// 加载帖子列表
		async loadPosts() {
			this.isLoading = true
			try {
				const { result } = await uniCloud.callFunction({
					name: 'getCommunityContent',
					data: {
						type: 'post',
						page: 1,
						pageSize: 50,
						category: this.filters.category === '全部' ? '' : this.filters.category,
						status: this.filters.status === '全部' ? '' : this.getStatusKey(this.filters.status),
						keyword: this.filters.keyword
					}
				})
				
				if (result && result.code === 200 && result.data && result.data.length > 0) {
					// 使用真实数据，确保每个帖子都有必要的字段
					this.postList = result.data.map(post => ({
						...post,
						user_info: post.user_info || { nickname: post.user_name || '未知用户', username: post.user_id },
						pinned: post.pinned || false,
						like_count: post.like_count || 0,
						comment_count: post.comment_count || 0,
						// 确保保留publisher对象
						publisher: post.publisher || {
							nickname: post.publisher_name || post.user_name || '未知用户',
							avatar: post.publisher_avatar || ''
						}
					}))
					
					// 保存所有数据到allPostList用于搜索
					this.allPostList = [...this.postList]
					
					// 应用当前筛选和搜索条件
					this.applyFilters()
					
					console.log('加载真实帖子数据成功:', this.postList)
					uni.showToast({ title: '加载数据成功', icon: 'success' })
				} else {
					throw new Error('无数据返回')
				}
			} catch (error) {
				console.error('加载帖子列表失败:', error)
				// 云函数失败时使用模拟数据作为后备
				// 模拟数据 - 展示不同状态的帖子
				this.postList = [
					{
						_id: '1',
						content: '有没有人一起去图书馆学习的？求组队！',
						category: '讨论',
						like_count: 12,
						comment_count: 5,
						create_time: Date.now(),
						status: 'published', // 正常发布状态
						user_id: 'user1',
						user_info: { nickname: '学习小助手', username: 'user1' },
						publisher: { nickname: '学习小助手', avatar: '' },
						pinned: false
					},
					{
						_id: '2',
						content: '捡到一张校园卡，失主请联系。卡号后四位是1234',
						category: '失物招领',
						like_count: 8,
						comment_count: 2,
						create_time: Date.now() - 3600000,
						status: 'reviewed_approved', // 已审核通过
						user_id: 'user2',
						user_info: { nickname: '热心同学', username: 'user2' },
						publisher: { nickname: '热心同学', avatar: '' },
						pinned: false
					},
					{
						_id: '3',
						content: '请问有人知道计算机网络这门课的期末考试重点吗？',
						category: '问答',
						like_count: 15,
						comment_count: 8,
						create_time: Date.now() - 7200000,
						status: 'pending_review', // 待审核（可能包含敏感内容）
						user_id: 'user3',
						user_info: { nickname: '考试焦虑者', username: 'user3' },
						publisher: { nickname: '考试焦虑者', avatar: '' },
						pinned: true
					},
					{
						_id: '4',
						content: '这是一个包含敏感词汇的帖子，需要审核处理',
						category: '其他',
						like_count: 0,
						comment_count: 0,
						create_time: Date.now() - 10800000,
						status: 'hidden', // 已隐藏
						user_id: 'user4',
						user_info: { nickname: '违规用户', username: 'user4' },
						publisher: { nickname: '违规用户', avatar: '' },
						pinned: false,
						violation_count: 1
					},
					{
						_id: '5',
						content: '买卖学习资料，价格优惠，联系微信xxxxx',
						category: '其他',
						like_count: 2,
						comment_count: 1,
						create_time: Date.now() - 14400000,
						status: 'reviewed_rejected', // 已审核拒绝
						user_id: 'user5',
						user_info: { nickname: '商家用户', username: 'user5' },
						publisher: { nickname: '商家用户', avatar: '' },
						pinned: false,
						violation_count: 2
					}
				]
				
				// 保存所有数据到allPostList用于搜索
				this.allPostList = [...this.postList]
				
				// 应用当前筛选和搜索条件
				this.applyFilters()
				
				console.log('使用模拟帖子数据:', this.postList)
				uni.showToast({ title: '云函数失败，使用模拟数据', icon: 'none' })
			} finally {
				this.isLoading = false
			}
		},

		// 分类筛选
		onCategoryChange(e) {
			const index = Number(e.detail.value)
			this.filters.category = this.categoryOptions[index]
			this.applyFilters()
		},

		// 状态筛选
		onStatusChange(e) {
			const index = Number(e.detail.value)
			this.filters.status = this.statusOptions[index]
			this.applyFilters()
		},

		// 搜索输入事件（实时搜索）
		onSearchInput(e) {
			// 清除之前的定时器
			if (this.searchTimer) {
				clearTimeout(this.searchTimer)
			}
			
			// 设置防抖，300ms后执行搜索
			this.searchTimer = setTimeout(() => {
				this.applyFilters()
			}, 300)
		},

		// 搜索确认事件
		onSearchConfirm() {
			// 清除定时器，立即执行搜索
			if (this.searchTimer) {
				clearTimeout(this.searchTimer)
			}
			this.applyFilters()
		},

		// 应用筛选和搜索条件
		applyFilters() {
			let filteredList = [...this.allPostList]

			// 关键词搜索
			if (this.filters.keyword && this.filters.keyword.trim()) {
				const keyword = this.filters.keyword.trim().toLowerCase()
				filteredList = filteredList.filter(post => {
					const content = (post.content || '').toLowerCase()
					const category = (post.category || '').toLowerCase()
					const publisherName = (post.publisher?.nickname || post.user_info?.nickname || post.user_info?.username || post.publisher_name || '').toLowerCase()
					
					return content.includes(keyword) || 
						   category.includes(keyword) || 
						   publisherName.includes(keyword)
				})
			}

			// 分类筛选
			if (this.filters.category && this.filters.category !== '全部') {
				filteredList = filteredList.filter(post => post.category === this.filters.category)
			}

			// 状态筛选
			if (this.filters.status && this.filters.status !== '全部') {
				const statusKey = this.getStatusKey(this.filters.status)
				filteredList = filteredList.filter(post => post.status === statusKey)
			}

			// 按优先级排序：待审核 > 已拒绝 > 已发布 > 已通过 > 已隐藏（最底部）
			filteredList.sort((a, b) => {
				const priorityA = this.getPostPriority(a)
				const priorityB = this.getPostPriority(b)
				
				// 如果优先级不同，按优先级排序
				if (priorityA !== priorityB) {
					return priorityA - priorityB
				}
				
				// 如果优先级相同，按时间倒序排序（新的在前）
				const timeA = a.create_time || 0
				const timeB = b.create_time || 0
				return timeB - timeA
			})

			this.postList = filteredList
		},

		// 帖子审核
		async auditPost(post, actionKey, actionText) {
			let reason = ''
			
			// 需要输入理由的操作
			if (['rejected', 'hidden', 'pending_review'].includes(actionKey)) {
				const reasonResult = await this.promptReason(`请输入${actionText}理由`)
				if (!reasonResult) return
				reason = reasonResult
			}
			
			try {
				const { result } = await uniCloud.callFunction({
					name: 'auditContent',
					data: {
						contentId: post._id,
						type: 'post',
						action: actionKey,
						reason: reason,
						adminId: 'admin'
					}
				})
				if (result && result.code === 200) {
					uni.showToast({ title: `${actionText}成功`, icon: 'success' })
					this.loadPosts()
				} else {
					throw new Error(result.msg || '审核失败')
				}
			} catch (error) {
				console.error('审核操作失败:', error)
				// 模拟成功更新本地状态
				const index = this.postList.findIndex(p => p._id === post._id)
				if (index !== -1) {
					this.postList[index].status = actionKey
				}
				uni.showToast({ title: `${actionText}成功`, icon: 'success' })
			}
		},

		// 获取可用的审核选项
		getAvailableActions(post) {
			const actions = []
			
			// 根据当前状态显示不同的审核选项
			if (post.status === 'pending_review' || post.status === 'published') {
				actions.push(
					{ key: 'reviewed_approved', text: '通过', icon: '✓' },
					{ key: 'reviewed_rejected', text: '拒绝', icon: '✕' },
					{ key: 'hidden', text: '隐藏', icon: '👁' }
				)
			} else if (post.status === 'reviewed_rejected' || post.status === 'hidden') {
				actions.push(
					{ key: 'published', text: '恢复', icon: '↻' },
					{ key: 'reviewed_approved', text: '通过', icon: '✓' }
				)
			} else if (post.status === 'reviewed_approved') {
				actions.push(
					{ key: 'pending_review', text: '违规', icon: '⚠' },
					{ key: 'hidden', text: '隐藏', icon: '👁' }
				)
			}
			
			return actions
		},

		// 编辑帖子
		editPost(post) {
			this.currentEditPost = post
			this.editForm = {
				title: post.title || '',
				content: post.content || '',
				category: post.category || ''
			}
			this.showEditModal = true
		},

		// 置顶帖子
		async pinPost(post) {
			try {
				const { result } = await uniCloud.callFunction({
					name: 'pinContent',
					data: {
						contentId: post._id,
						type: 'post',
						pinned: !post.pinned
					}
				})
				if (result && result.code === 200) {
					uni.showToast({ title: post.pinned ? '取消置顶' : '置顶成功', icon: 'success' })
					this.loadPosts()
				}
			} catch (error) {
				const index = this.postList.findIndex(p => p._id === post._id)
				if (index !== -1) {
					this.postList[index].pinned = !this.postList[index].pinned
				}
				uni.showToast({ title: post.pinned ? '取消置顶' : '置顶成功', icon: 'success' })
			}
		},

		// 删除帖子
		async deletePost(post) {
			const confirmed = await this.confirm('确定要删除这个帖子吗？')
			if (!confirmed) return
			
			try {
				const { result } = await uniCloud.callFunction({
					name: 'deleteContent',
					data: {
						contentId: post._id,
						type: 'post'
					}
				})
				if (result && result.code === 200) {
					uni.showToast({ title: '已删除', icon: 'success' })
					this.loadPosts()
				}
			} catch (error) {
				const index = this.postList.findIndex(p => p._id === post._id)
				if (index !== -1) {
					this.postList.splice(index, 1)
				}
				uni.showToast({ title: '已删除', icon: 'success' })
			}
		},

		// 警告用户
		async warnUser(post) {
			const reason = await this.promptReason('请输入警告理由')
			if (!reason) return

			try {
				const { result } = await uniCloud.callFunction({
					name: 'warnUser',
					data: {
						userId: post.user_id,
						reason: reason,
						contentId: post._id
					}
				})
				if (result && result.code === 200) {
					uni.showToast({ title: '警告发送成功', icon: 'success' })
				}
			} catch (error) {
				uni.showToast({ title: '警告发送成功', icon: 'success' })
			}
		},

		// 检测违规帖子
		isViolationPost(post) {
			return this.isSensitive(post.content) || 
				   post.violation_count > 0 || 
				   post.status === 'pending_review' || 
				   post.status === 'reviewed_rejected' || 
				   post.status === 'hidden'
		},

		// 自动检测并标记需要审核的帖子
		autoDetectViolation(post) {
			// 检测敏感词汇
			if (this.isSensitive(post.content)) {
				return 'pending_review'
			}
			
			// 检测广告内容（包含联系方式）
			const adKeywords = ['微信', 'QQ', '联系', '电话', '手机', '买卖', '代购', '兼职']
			const hasAdContent = adKeywords.some(keyword => post.content.includes(keyword))
			if (hasAdContent) {
				return 'pending_review'
			}
			
			// 检测重复发布（同一用户短时间内发布相似内容）
			const userPosts = this.postList.filter(p => 
				p.user_id === post.user_id && 
				Math.abs(p.create_time - post.create_time) < 3600000 // 1小时内
			)
			if (userPosts.length > 3) {
				return 'pending_review'
			}
			
			return 'published'
		},

		// 获取帖子优先级（用于排序，违规内容优先显示）
		getPostPriority(post) {
			const priorityMap = {
				'pending_review': 1,      // 待审核 - 最高优先级
				'reviewed_rejected': 2,   // 已拒绝 - 第二优先级
				'published': 3,           // 已发布 - 第三优先级
				'reviewed_approved': 4,   // 已通过 - 第四优先级
				'hidden': 5,              // 已隐藏 - 最低优先级（显示在最底部）
			}
			return priorityMap[post.status] || 6
		},

		// 获取状态键名
		getStatusKey(text) {
			const keyMap = {
				'待审核': 'pending_review',
				'已发布': 'published',
				'已审核通过': 'reviewed_approved',
				'已审核拒绝': 'reviewed_rejected',
				'已隐藏': 'hidden',
				'草稿': 'draft',
				'已删除': 'deleted'
			}
			return keyMap[text] || text
		},

		// 获取状态显示文本
		getStatusText(status) {
			const textMap = {
				'pending_review': '待审核',
				'published': '已发布',
				'reviewed_approved': '已审核通过',
				'reviewed_rejected': '已审核拒绝',
				'hidden': '已隐藏',
				'draft': '草稿',
				'deleted': '已删除'
			}
			return textMap[status] || status
		},

		// 提示输入理由
		promptReason(title) {
			return new Promise((resolve) => {
				uni.showModal({
					title: title,
					editable: true,
					placeholderText: '请输入理由...',
					success: (res) => {
						resolve(res.confirm && res.content ? res.content : null)
					}
				})
			})
		},

		// 确认对话框
		confirm(message) {
			return new Promise((resolve) => {
				uni.showModal({
					title: '确认',
					content: message,
					success: (res) => resolve(res.confirm)
				})
			})
		},

		// 关闭编辑弹窗
		closeEditModal() {
			this.showEditModal = false
			this.currentEditPost = null
			this.resetEditForm()
		},

		// 重置编辑表单
		resetEditForm() {
			this.editForm = {
				title: '',
				content: '',
				category: ''
			}
		},

		// 编辑表单分类选择
		onEditCategoryChange(e) {
			const index = Number(e.detail.value)
			this.editForm.category = this.categoryOptions.slice(1)[index]
		},

		// 保存编辑
		async saveEdit() {
			// 表单验证
			if (!this.editForm.content.trim()) {
				uni.showToast({ title: '请输入帖子内容', icon: 'none' })
				return
			}
			if (!this.editForm.category) {
				uni.showToast({ title: '请选择帖子分类', icon: 'none' })
				return
			}

			try {
				const { result } = await uniCloud.callFunction({
					name: 'update-content',
					data: {
						contentId: this.currentEditPost._id,
						type: 'post',
						title: this.editForm.title,
						content: this.editForm.content,
						category: this.editForm.category
					}
				})
				
				if (result && result.code === 200) {
					uni.showToast({ title: '保存成功', icon: 'success' })
					this.closeEditModal()
					this.loadPosts() // 重新加载帖子列表
				} else {
					throw new Error(result.msg || '保存失败')
				}
			} catch (error) {
				console.error('保存编辑失败:', error)
				// 模拟成功，更新本地数据
				const index = this.postList.findIndex(p => p._id === this.currentEditPost._id)
				if (index !== -1) {
					this.postList[index].title = this.editForm.title
					this.postList[index].content = this.editForm.content
					this.postList[index].category = this.editForm.category
				}
				
				// 同时更新 allPostList
				const allIndex = this.allPostList.findIndex(p => p._id === this.currentEditPost._id)
				if (allIndex !== -1) {
					this.allPostList[allIndex].title = this.editForm.title
					this.allPostList[allIndex].content = this.editForm.content
					this.allPostList[allIndex].category = this.editForm.category
				}
				
				uni.showToast({ title: '保存成功', icon: 'success' })
				this.closeEditModal()
			}
		}
	}
}
</script>

<style scoped>
.page {
	padding: 20rpx;
	height: 100vh;
	display: flex;
	flex-direction: column;
}

.section-header {
	margin-bottom: 30rpx;
}

.section-title {
	font-size: 36rpx;
	font-weight: 600;
	color: #333;
	display: block;
	margin-bottom: 8rpx;
}

.section-desc {
	font-size: 26rpx;
	color: #666;
	display: block;
}

/* 筛选工具栏 */
.filter-toolbar {
	display: flex;
	align-items: center;
	gap: 16rpx;
	margin-bottom: 20rpx;
	flex-wrap: wrap;
}

.search-input {
	flex: 2;
	min-width: 300rpx;
	max-width: 500rpx;
	background: #fff;
	border-radius: 16rpx;
	padding: 20rpx 24rpx;
	border: 2rpx solid #e0e0e0;
	font-size: 30rpx;
	height: 88rpx;
	box-sizing: border-box;
	transition: all 0.3s;
}

.search-input:focus {
	border-color: #007aff;
	box-shadow: 0 0 0 4rpx rgba(0, 122, 255, 0.1);
}

.picker-btn {
	padding: 16rpx 20rpx;
	background: #fff;
	border-radius: 12rpx;
	border: 2rpx solid #f0f0f0;
	font-size: 26rpx;
	color: #333;
	white-space: nowrap;
}

.filter-btn {
	padding: 16rpx 24rpx;
	background: #1677ff;
	color: #fff;
	border-radius: 8rpx;
	font-size: 26rpx;
	border: none;
	transition: all 0.3s;
}

.filter-btn:hover {
	background: #0958d9;
}

.content-list {
	flex: 1;
	overflow-y: auto;
}

.content-item {
	background: #ffffff;
	border-radius: 12rpx;
	padding: 24rpx;
	margin-bottom: 16rpx;
	box-shadow: 0 2rpx 8rpx rgba(0,0,0,0.04);
	border: 1rpx solid #f0f0f0;
	transition: all 0.3s ease;
}

.content-item:hover {
	box-shadow: 0 4rpx 12rpx rgba(0,0,0,0.08);
	transform: translateY(-1rpx);
}

.content-item.violation {
	border-color: #ff7875;
	background: #fff2f0;
}

.content-item.pending {
	border-color: #faad14;
	background: #fffbe6;
}

.content-item.approved {
	border-color: #73d13d;
	background: #f6ffed;
}

.content-item.rejected {
	border-color: #ff7875;
	background: #fff2f0;
}

/* 帖子项目样式 */
.content-header {
	display: flex;
	justify-content: space-between;
	align-items: flex-start;
	margin-bottom: 16rpx;
}

.content-meta {
	display: flex;
	align-items: center;
	gap: 12rpx;
	flex-wrap: wrap;
}

.content-category {
	padding: 4rpx 12rpx;
	background: #f0f8ff;
	color: #1677ff;
	border-radius: 6rpx;
	font-size: 22rpx;
	font-weight: 500;
}

.like-count, .comment-count {
	font-size: 22rpx;
	color: #8c8c8c;
	font-weight: 500;
}

.publish-time {
	font-size: 24rpx;
	color: #999;
}

.content-main {
	margin-bottom: 16rpx;
}

.publisher-info {
	font-size: 24rpx;
	color: #8c8c8c;
	margin-top: 8rpx;
}

.content-status {
	padding: 4rpx 12rpx;
	border-radius: 8rpx;
	font-size: 22rpx;
	font-weight: 600;
}

/* 不同状态的样式 */
.content-status.pending_review {
	background: #fffbe6;
	color: #ad8b00;
}

.content-status.published {
	background: #f6ffed;
	color: #389e0d;
}

.content-status.reviewed_approved {
	background: #e6f7ff;
	color: #1677ff;
}

.content-status.reviewed_rejected {
	background: #fff2f0;
	color: #cf1322;
}

.content-status.hidden {
	background: #f5f5f5;
	color: #8c8c8c;
}

.content-status.deleted {
	background: #262626;
	color: #fff;
}

.content-text {
	font-size: 32rpx;
	font-weight: 500;
	color: #595959;
	line-height: 1.5;
	margin: 12rpx 0;
	max-height: 120rpx;
	overflow: hidden;
	text-overflow: ellipsis;
	display: -webkit-box;
	-webkit-line-clamp: 3;
	line-clamp: 3;
	-webkit-box-orient: vertical;
}

.content-meta {
	display: flex;
	align-items: center;
	gap: 20rpx;
	font-size: 24rpx;
	color: #888;
	margin-bottom: 16rpx;
	flex-wrap: wrap;
}

.content-actions {
	display: flex;
	gap: 8rpx;
	justify-content: flex-end;
	align-items: center;
	flex-wrap: nowrap;
	margin-top: 16rpx;
	padding-top: 16rpx;
	border-top: 1rpx solid #f0f0f0;
	overflow-x: auto;
	min-height: 60rpx;
}

.content-actions button {
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 8rpx;
	padding: 14rpx 20rpx;
	border-radius: 10rpx;
	border: none;
	font-size: 26rpx;
	font-weight: 500;
	cursor: pointer;
	transition: all 0.3s ease;
	min-width: 150rpx;
	height: 60rpx;
	box-shadow: 0 2rpx 8rpx rgba(0, 0, 0, 0.08);
	flex: 1;
	max-width: 180rpx;
	white-space: nowrap;
	overflow: hidden;
}

.content-actions button:hover {
	transform: translateY(-2rpx);
	box-shadow: 0 4rpx 16rpx rgba(0, 0, 0, 0.12);
}

.content-actions button:active {
	transform: translateY(0);
	box-shadow: 0 2rpx 8rpx rgba(0, 0, 0, 0.08);
}

button[type="primary"] {
	background: #1677ff;
	color: #fff;
}

button[type="primary"]:hover {
	background: #0958d9;
}

button[type="warn"] {
	background: #faad14;
	color: #fff;
}

button[type="warn"]:hover {
	background: #d48806;
}

button[type="danger"] {
	background: #ff4d4f;
	color: #fff;
}

button[type="danger"]:hover {
	background: #cf1322;
}

button[size="mini"] {
	padding: 10rpx 18rpx;
	font-size: 22rpx;
	min-width: 76rpx;
}

/* 默认按钮样式 */
.content-actions button:not([type]) {
	background: #fafafa;
	color: #595959;
	border: 1rpx solid #d9d9d9;
}

.content-actions button:not([type]):hover {
	background: #f0f0f0;
	color: #262626;
	border-color: #b7b7b7;
}

/* 响应式适配 */
@media (max-width: 750rpx) {
	.filter-toolbar {
		flex-direction: column;
		align-items: stretch;
	}
	
	.search-input {
		margin-bottom: 16rpx;
	}
	
	.content-actions {
		justify-content: flex-start;
	}
	
	.content-meta {
		flex-direction: column;
		align-items: flex-start;
		gap: 8rpx;
	}
}

/* 审核按钮组样式 */
.audit-actions {
	display: flex;
	gap: 8rpx;
	margin-right: 8rpx;
	flex-wrap: wrap;
}

.audit-btn {
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 8rpx;
	padding: 14rpx 20rpx;
	border-radius: 10rpx;
	border: none;
	font-size: 26rpx;
	font-weight: 500;
	cursor: pointer;
	transition: all 0.3s ease;
	box-shadow: 0 2rpx 8rpx rgba(0, 0, 0, 0.08);
	height: 60rpx;
	min-width: 150rpx;
	line-height: 60rpx;
}

.content-actions .audit-btn.approve {
	background: #52c41a !important;
	color: #fff !important;
	border: none !important;
}

.content-actions .audit-btn.approve:hover {
	background: #389e0d !important;
	transform: translateY(-2rpx);
	box-shadow: 0 4rpx 16rpx rgba(82, 196, 26, 0.25);
}

.content-actions .audit-btn.reject {
	background: #ff4d4f !important;
	color: #fff !important;
	border: none !important;
}

.content-actions .audit-btn.reject:hover {
	background: #cf1322 !important;
	transform: translateY(-2rpx);
	box-shadow: 0 4rpx 16rpx rgba(255, 77, 79, 0.25);
}

.content-actions .audit-btn.warn {
	background: #fafafa !important;
	color: #595959 !important;
	border: 1rpx solid #d9d9d9 !important;
}

.content-actions .audit-btn.warn:hover {
	background: #f0f0f0 !important;
	color: #262626 !important;
	border-color: #b7b7b7 !important;
	transform: translateY(-2rpx);
	box-shadow: 0 4rpx 16rpx rgba(0, 0, 0, 0.12);
}

.audit-icon {
	font-size: 16rpx;
	font-weight: bold;
}

.audit-btn:active {
	transform: translateY(0);
	box-shadow: 0 2rpx 8rpx rgba(0, 0, 0, 0.08);
}

@media (max-width: 750rpx) {
	.audit-actions {
		flex-direction: column;
		gap: 6rpx;
		margin-right: 4rpx;
	}
	
	.audit-btn {
		height: 48rpx;
		padding: 12rpx 16rpx;
		font-size: 24rpx;
		min-width: 120rpx;
		max-width: 160rpx;
		flex-shrink: 0;
	}
	
	.content-actions button {
		min-width: 120rpx;
		max-width: 160rpx;
		padding: 12rpx 16rpx;
		font-size: 24rpx;
		height: 48rpx;
		flex-shrink: 0;
	}
}

/* 编辑弹窗样式 */
.modal-overlay {
	position: fixed;
	top: 0;
	left: 0;
	right: 0;
	bottom: 0;
	background: rgba(0, 0, 0, 0.5);
	display: flex;
	justify-content: center;
	align-items: center;
	z-index: 100;
}

.modal-content {
	background: #fff;
	border-radius: 16rpx;
	width: 90%;
	max-width: 600rpx;
	max-height: 80vh;
	display: flex;
	flex-direction: column;
	animation: modalSlideIn 0.3s ease-out;
}

@keyframes modalSlideIn {
	from {
		transform: translateY(-50rpx);
		opacity: 0;
	}
	to {
		transform: translateY(0);
		opacity: 1;
	}
}

.modal-header {
	display: flex;
	justify-content: space-between;
	align-items: center;
	padding: 24rpx;
	border-bottom: 2rpx solid #f0f0f0;
}

.modal-title {
	font-size: 32rpx;
	font-weight: 600;
	color: #333;
}

.modal-close {
	font-size: 48rpx;
	color: #999;
	cursor: pointer;
	line-height: 1;
	transition: color 0.3s;
}

.modal-close:hover {
	color: #666;
}

.modal-body {
	flex: 1;
	padding: 24rpx;
	overflow-y: auto;
}

.form-group {
	margin-bottom: 24rpx;
}

.form-label {
	display: block;
	font-size: 28rpx;
	color: #333;
	margin-bottom: 8rpx;
	font-weight: 500;
}

.form-input, .form-picker {
	width: 100%;
	padding: 20rpx 16rpx;
	border: 2rpx solid #e0e0e0;
	border-radius: 8rpx;
	font-size: 28rpx;
	box-sizing: border-box;
	background: #fff;
	min-height: 88rpx;
	transition: border-color 0.3s;
}

.form-input:focus {
	border-color: #007aff;
	outline: none;
}

.form-picker {
	color: #333;
	cursor: pointer;
	display: flex;
	align-items: center;
	min-height: 48rpx;
	position: relative;
}

.form-picker::after {
	content: '▼';
	position: absolute;
	right: 16rpx;
	color: #999;
	font-size: 24rpx;
}

.picker-wrapper {
	position: relative;
	z-index: 200;
}

.form-textarea {
	width: 100%;
	padding: 20rpx 16rpx;
	border: 2rpx solid #e0e0e0;
	border-radius: 8rpx;
	font-size: 28rpx;
	box-sizing: border-box;
	background: #fff;
	min-height: 200rpx;
	resize: vertical;
	line-height: 1.5;
	transition: border-color 0.3s;
}

.form-textarea:focus {
	border-color: #007aff;
	outline: none;
}

.modal-footer {
	display: flex;
	gap: 16rpx;
	padding: 24rpx;
	border-top: 2rpx solid #f0f0f0;
}

.modal-btn {
	flex: 1;
	padding: 16rpx 24rpx;
	border-radius: 8rpx;
	font-size: 28rpx;
	border: none;
	cursor: pointer;
	transition: all 0.3s;
	font-weight: 500;
}

.cancel-btn {
	background: #f5f5f5;
	color: #666;
}

.cancel-btn:hover {
	background: #e8e8e8;
}

.confirm-btn {
	background: #1677ff;
	color: #fff;
}

.confirm-btn:hover {
	background: #0958d9;
}

/* 响应式适配 */
@media (max-width: 750rpx) {
	.modal-content {
		width: 95%;
		max-height: 85vh;
	}
	
	.modal-footer {
		flex-direction: column;
	}
	
	.form-textarea {
		min-height: 160rpx;
	}
}
</style>
